package cn.com.generaldata.os.service.common;

import org.nutz.dao.Dao;
import org.nutz.dao.impl.sql.SqlTemplate;
import org.nutz.lang.Mirror;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.generaldata.jsme_indicator_system.entity.ReportTypeNz;
import cn.com.generaldata.os.pojo.mvc.Row;
import cn.com.generaldata.os.service.impl.web.UnitServiceForWeb;
import cn.com.generaldata.os.vo.ReportStatResult;
import cn.com.generaldata.os.vo.ReportStatVO;

/**
 * 报表形式指标汇总Service.
 */
@Service
public class ReportStatService {

	protected final Mirror<Row> mirror = Mirror.me(Row.class);

	@Autowired
	private Dao indicatorSystemDao;

	@Autowired
	private SqlTemplate sqlTemplate;

	@Autowired
	private ReportTemplateService reportTemplateService;

	@Autowired
	private UnitServiceForWeb unitService;

	/**
	 * 报表形式指标汇总
	 * 
	 * @param ReportStatVO
	 * @return
	 */
	public ReportStatResult stat(ReportStatVO reportStatVO) {
		ReportTypeNz reportType = indicatorSystemDao.fetch(ReportTypeNz.class, reportStatVO.getReportTypeId());

		ReportStatResult result = new ReportStatResult();
		// result.setOriginalReportHtml(getOriginalReportHtml(reportType, reportStatVO));
		// result.setStatReportHtml(getStatReportHtml(reportType, reportStatVO));
		return result;

	}

	// /**
	// * 获取原始的信息
	// *
	// * @param reportType
	// * @param reportStatVO
	// * @return
	// */
	// private String getOriginalReportHtml(ReportType reportType, ReportStatVO reportStatVO) {
	// reportStatVO.setResultType(ReportStatVO.RESULT_TYPE_ORI);
	// List<Row> rows = null;
	// if (reportType.getDataType().intValue() == Constants.ReportStyle.CELL.getValue()) {
	// rows = genCellReportRows(reportStatVO, reportType);
	// } else {
	// rows = genRowReportRows(reportStatVO, reportType);
	// }
	//
	// Report report = new Report();
	// report.setReportTimetype(reportStatVO.getFrequency().toString());
	// report.setReportYear(reportStatVO.getYear().toString());
	// report.setReportYearTime(Castors.me().castTo(reportStatVO.getYearTime(), String.class));
	// report.setReportQuarter(Castors.me().castTo(reportStatVO.getQuarter(), String.class));
	// report.setReportMonth(Castors.me().castTo(reportStatVO.getMonth(), String.class));
	// // report.setRows(rows);
	//
	// return reportTemplateService.renderUpdateTemplate(reportType.getId(), rows, report, null);
	// }
	//
	// /**
	// * 获取汇总的信息
	// *
	// * @param reportType
	// * @param reportStatVO
	// * @return
	// */
	// private String getStatReportHtml(ReportType reportType, ReportStatVO reportStatVO) {
	// reportStatVO.setResultType(ReportStatVO.RESULT_TYPE_STAT);
	// List<Row> rows = null;
	// if (reportType.getDataType().intValue() == Constants.ReportStyle.CELL.getValue()) {
	// rows = genCellReportRows(reportStatVO, reportType);
	// } else {
	// rows = genRowReportRows(reportStatVO, reportType);
	// }
	//
	// Report report = new Report();
	// report.setReportTimetype(reportStatVO.getFrequency().toString());
	// report.setReportYear(reportStatVO.getYear().toString());
	// report.setReportYearTime(Castors.me().castTo(reportStatVO.getYearTime(), String.class));
	// report.setReportQuarter(Castors.me().castTo(reportStatVO.getQuarter(), String.class));
	// report.setReportMonth(Castors.me().castTo(reportStatVO.getMonth(), String.class));
	// // report.setRows(rows);
	//
	// return reportTemplateService.renderUpdateTemplate(reportType.getId(), rows, report, null);
	// }
	//
	// /**
	// * 获取报表与对应指标的关系.
	// *
	// * @param reportStatVO 汇总条件VO
	// * @param reportType 报表类型对象
	// * @return
	// */
	// private List<ReportTypeIndicatorVO> getReportTypeIndicatorRel(ReportStatVO reportStatVO, ReportType reportType) {
	// List<ReportTypeIndicatorVO> list = Lists.newArrayList();
	// Condition cnd = Cnd.where("reportTypeId", "=", reportType.getId()).asc("row").asc("theColumn");
	// if (reportType.getStatSystem() == Constants.ReportStatSystem.PROVINCE.getValue()) {
	// List<ReportTypeIndicator> rels = indicatorSystemDao.query(ReportTypeIndicator.class, cnd);
	// for (ReportTypeIndicator rel : rels) {
	// rel = indicatorSystemDao.fetchLinks(rel, null);
	// ReportTypeIndicatorVO rtiVO = new ReportTypeIndicatorVO();
	// rtiVO.setReportTypeId(reportType.getId());
	// rtiVO.setIndicatorId(rel.getIndicatorId());
	// rtiVO.setRow(rel.getRow());
	// rtiVO.setTheColumn(rel.getTheColumn());
	// rtiVO.setDataType(rel.getIndicator().getDataType());
	// list.add(rtiVO);
	// }
	// } else {
	// List<ReportTypeIndicatorSystemReport> rels = indicatorSystemDao.query(
	// ReportTypeIndicatorSystemReport.class, cnd);
	// for (ReportTypeIndicatorSystemReport rel : rels) {
	// rel = indicatorSystemDao.fetchLinks(rel, null);
	// ReportTypeIndicatorVO rtiVO = new ReportTypeIndicatorVO();
	// rtiVO.setReportTypeId(reportType.getId());
	// rtiVO.setIndicatorId(rel.getIndicatorId());
	// rtiVO.setRow(rel.getRow());
	// rtiVO.setTheColumn(rel.getTheColumn());
	// rtiVO.setDataType(rel.getIndicator().getDataType());
	// list.add(rtiVO);
	// }
	// }
	// return list;
	// }
	//
	// /**
	// * 生成行式报表数据行
	// *
	// * @param reportStatVO 汇总条件VO
	// * @param reportType 报表类型对象
	// * @return
	// */
	// private List<Row> genRowReportRows(ReportStatVO reportStatVO, ReportType reportType) {
	// List<ReportTypeIndicatorVO> reportIndicatorRels = getReportTypeIndicatorRel(reportStatVO, reportType);
	//
	// // 获取主列
	// ReportTypeIndicatorVO masterIndicator = getRowReportMasterIndicator(reportIndicatorRels, reportType);
	// // 获取数据列
	// List<ReportTypeIndicatorVO> dataIndicators = getRowReportDataIndicators(reportIndicatorRels, masterIndicator);
	// // 获取所有唯一主列值
	// List<String> masterColumnValues = getMasterColumnValues(reportStatVO, masterIndicator);
	//
	// List<Row> rows = makeRowReportRows(reportStatVO, masterIndicator, dataIndicators, masterColumnValues);
	// return rows;
	// }
	//
	// private List<Row> makeRowReportRows(ReportStatVO reportStatVO, ReportTypeIndicatorVO masterIndicator,
	// List<ReportTypeIndicatorVO> dataIndicators, List<String> masterColumnValues) {
	// // 循环主列把对应的子列数据取出，拼成一行
	// List<Row> rows = Lists.newArrayList();
	// for (int i = 0; i < masterColumnValues.size(); i++) {
	// String masterColumnValue = masterColumnValues.get(i);
	// Row row = new Row();
	// row.setRowIndex(i);
	// String masterrColumnFileName = String.format("f%s", masterIndicator.getTheColumn());
	// mirror.setValue(row, masterrColumnFileName, masterColumnValue);
	// for (ReportTypeIndicatorVO dataIndicator : dataIndicators) {
	// String data = getDataColumnValue(reportStatVO, masterColumnValue, masterIndicator, dataIndicator);
	// String fieldName = String.format("f%s", dataIndicator.getTheColumn());
	// mirror.setValue(row, fieldName, data);
	// }
	// rows.add(row);
	// }
	// return rows;
	// }
	//
	// private String getDataColumnValue(ReportStatVO reportStatVO, String masterValue,
	// ReportTypeIndicatorVO masterIndicator, ReportTypeIndicatorVO dataIndicator) {
	// String sql = "SELECT SUM(rd.$dataColumn) FROM "
	// + " tbl_report r INNER JOIN tbl_report_detail rd ON r.id = rd.report_id "
	// +
	// " INNER JOIN tbl_report_unit ru ON ru.report_id = r.id AND ru.operator_unit = @provinceUnitId AND ru.check_status = '5' "
	// + " INNER JOIN tbl_user u ON r.report_user_id = u.id "
	// + " INNER JOIN tbl_unit unit ON u.user_unit = unit.id "
	// + " INNER JOIN tbl_area area ON unit.unit_area_id = area.id " + " WHERE "
	// + " r.report_check_status = '5' AND u.user_role_id IN ('4','5') "
	// + " AND r.report_type_id = @reportTypeId " + " rd.$masterColumn = @masterValue ";
	// if (reportStatVO.getFrequency() == 0) {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.month = @month ";
	// } else if (reportStatVO.getFrequency() == 1) {
	// sql +=
	// " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.report_year_time = @reportYearTime ";
	// } else {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.quarter = @quarter ";
	// }
	//
	// if (ReportStatVO.RESULT_TYPE_ORI.equals(reportStatVO.getResultType())) {
	// sql += " AND area.id = @areaId ";
	// } else {
	// sql += " AND area.parent_id = @areaId ";
	// }
	//
	// sql += " GROUP BY rd.$dataColumn";
	//
	// Map<String, Object> params = reportStatVOToParamMap(reportStatVO);
	// params.put("provinceUnitId", unitService.getProvinceOceanUnit().getId());
	// params.put("areaId", reportStatVO.getQueryAreaId());
	// params.put("masterValue", masterValue);
	//
	// Map<String, Object> vars = Maps.newHashMap();
	// vars.put("masterColumn", "f" + masterIndicator.getTheColumn().intValue());
	// vars.put("dataColumn", "f" + dataIndicator.getTheColumn().intValue());
	//
	// return sqlTemplate.queryForObject(sql, vars, params, String.class);
	// }
	//
	// /**
	// * 获取主列的所有唯一值
	// *
	// * @param reportStatVO
	// * @param masterIndicator
	// * @return
	// */
	// private List<String> getMasterColumnValues(ReportStatVO reportStatVO, ReportTypeIndicatorVO masterIndicator) {
	// String sql = "SELECT rd.$clomun FROM "
	// + " tbl_report r INNER JOIN tbl_report_detail rd ON r.id = rd.report_id "
	// +
	// " INNER JOIN tbl_report_unit ru ON ru.report_id = r.id AND ru.operator_unit = @provinceUnitId AND ru.check_status = '5' "
	// + " INNER JOIN tbl_user u ON r.report_user_id = u.id "
	// + " INNER JOIN tbl_unit unit ON u.user_unit = unit.id "
	// + " INNER JOIN tbl_area area ON unit.unit_area_id = area.id " + " WHERE "
	// + " r.report_check_status = '5' AND u.user_role_id IN ('4','5') ";
	// if (reportStatVO.getFrequency() == 0) {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.month = @month ";
	// } else if (reportStatVO.getFrequency() == 1) {
	// sql +=
	// " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.report_year_time = @reportYearTime ";
	// } else {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.quarter = @quarter ";
	// }
	//
	// Map<String, Object> params = reportStatVOToParamMap(reportStatVO);
	// params.put("provinceUnitId", unitService.getProvinceOceanUnit().getId());
	//
	// if (ReportStatVO.RESULT_TYPE_ORI.equals(reportStatVO.getResultType())) {
	// sql += " AND area.id = @areaId ";
	// } else {
	// sql += " AND area.parent_id = @areaId ";
	// }
	// params.put("areaId", reportStatVO.getQueryAreaId());
	//
	// sql += " GROUP BY rd.$clomun";
	//
	// Map<String, Object> vars = Maps.newHashMap();
	// vars.put("clomun", "f" + masterIndicator.getTheColumn().intValue());
	//
	// List<String> masterColumnValues = sqlTemplate.queryForList(sql, vars, params, String.class);
	//
	// return masterColumnValues;
	//
	// }
	//
	// private List<ReportTypeIndicatorVO> getRowReportDataIndicators(List<ReportTypeIndicatorVO> reportIndicatorRels,
	// ReportTypeIndicatorVO masterIndicator) {
	// List<ReportTypeIndicatorVO> dataIndicators = Lists.newArrayList();
	// for (ReportTypeIndicatorVO rel : reportIndicatorRels) {
	// if (rel.getIndicatorId().equals(masterIndicator.getIndicatorId())) {
	// continue;
	// }
	// if (rel.getDataType().intValue() == Constants.IndicatorDataType.NUMBER.getValue()) {
	// dataIndicators.add(rel);
	// }
	// }
	// return dataIndicators;
	// }
	//
	// /**
	// * 获取报表主列指标对应关系
	// *
	// * @param reportIndicatorRels 报表与指标对应集合
	// * @param reportType 报表类型
	// * @return
	// */
	// private ReportTypeIndicatorVO getRowReportMasterIndicator(List<ReportTypeIndicatorVO> reportIndicatorRels,
	// ReportType reportType) {
	// ReportTypeIndicatorVO masterIndicator = null;
	// for (ReportTypeIndicatorVO rel : reportIndicatorRels) {
	// if (rel.getTheColumn().intValue() == reportType.getMasterColumn().intValue()) {
	// masterIndicator = rel;
	// break;
	// }
	// }
	// return masterIndicator;
	// }
	//
	// /**
	// * 生成单元格式报表数据行
	// *
	// * @param reportStatVO
	// * @param reportType
	// * @return
	// */
	// private List<Row> genCellReportRows(ReportStatVO reportStatVO, ReportType reportType) {
	// List<ReportTypeIndicatorVO> reportIndicatorRels = getReportTypeIndicatorRel(reportStatVO, reportType);
	// List<Row> rows = Lists.newArrayList();
	//
	// // 转成table形式，方便处理
	// Table<Integer, Integer, ReportTypeIndicatorVO> reportTypeIndicatorTable = TreeBasedTable.create();
	// for (ReportTypeIndicatorVO rel : reportIndicatorRels) {
	// reportTypeIndicatorTable.put(rel.getRow(), rel.getTheColumn(), rel);
	// }
	//
	// for (Integer rowKey : reportTypeIndicatorTable.rowKeySet()) {
	// Row row = new Row();
	// row.setRowIndex(rowKey);
	// Map<Integer, ReportTypeIndicatorVO> rowMap = reportTypeIndicatorTable.row(rowKey);
	// for (Entry<Integer, ReportTypeIndicatorVO> entry : rowMap.entrySet()) {
	// ReportTypeIndicatorVO item = entry.getValue();
	//
	// String result = statColumnIndicator(reportStatVO, reportType, item);
	// String fieldName = String.format("f%d", entry.getKey());
	// if (result == null) {
	// mirror.setValue(row, fieldName, "");
	// } else {
	// mirror.setValue(row, fieldName, result);
	// }
	// }
	// rows.add(row);
	// }
	//
	// return rows;
	// }
	//
	// private String statColumnIndicator(ReportStatVO reportStatVO, ReportType reportType, ReportTypeIndicatorVO item)
	// {
	// String sql = "SELECT SUM(rd.$clomun) FROM "
	// + " tbl_report r INNER JOIN tbl_report_detail rd ON r.id = rd.report_id "
	// +
	// " INNER JOIN tbl_report_unit ru ON ru.report_id = r.id AND ru.operator_unit = @provinceUnitId AND ru.check_status = '5' "
	// + " INNER JOIN tbl_user u ON r.report_user_id = u.id "
	// + " INNER JOIN tbl_unit unit ON u.user_unit = unit.id "
	// + " INNER JOIN tbl_area area ON unit.unit_area_id = area.id " + " WHERE "
	// + " u.user_role_id IN ('4','5') AND r.report_check_status = '5' "
	// + " AND r.report_type_id = @reportTypeId " + " AND rd.row_index = @row ";
	// if (reportStatVO.getFrequency().intValue() == Constants.REPORT_TIME_MONTH) {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.month = @month ";
	// } else if (reportStatVO.getFrequency().intValue() == Constants.REPORT_TIME_YEAR) {
	// sql +=
	// " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.report_year_time = @reportYearTime ";
	// } else {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.quarter = @quarter ";
	// }
	//
	// Map<String, Object> params = reportStatVOToParamMap(reportStatVO);
	// params.put("provinceUnitId", unitService.getProvinceOceanUnit().getId());
	// if (ReportStatVO.RESULT_TYPE_ORI.equals(reportStatVO.getResultType())) {
	// sql += " AND area.id = @areaId ";
	// } else {
	// sql += " AND area.parent_id = @areaId ";
	// }
	// params.put("areaId", reportStatVO.getQueryAreaId());
	// params.put("row", item.getRow());
	//
	// Map<String, Object> vars = Maps.newHashMap();
	// vars.put("clomun", "f" + item.getTheColumn().intValue());
	//
	// String result = sqlTemplate.queryForObject(sql, vars, params, String.class);
	//
	// return result;
	// }
	//
	// private Map<String, Object> reportStatVOToParamMap(ReportStatVO reportStatVO) {
	// Map<String, Object> param = Maps.newHashMap();
	// param.put("reportTypeId", reportStatVO.getReportTypeId());
	// param.put("reportTimetype", reportStatVO.getFrequency() + "");
	// // param.put("areaParentId", reportStatVO.getQueryAreaId());
	// if (reportStatVO.getFrequency().intValue() == Constants.REPORT_TIME_MONTH) {
	// param.put("reportTimetype", "0");
	// param.put("reportYear", reportStatVO.getYear().toString());
	// param.put("month", reportStatVO.getMonth());
	// } else if (reportStatVO.getFrequency().intValue() == Constants.REPORT_TIME_YEAR) {
	// param.put("reportTimetype", "1");
	// param.put("reportYear", reportStatVO.getYear().toString());
	// param.put("reportYearTime", reportStatVO.getYearTime());
	// } else {
	// param.put("reportTimetype", "2");
	// param.put("reportYear", reportStatVO.getYear().toString());
	// param.put("quarter", reportStatVO.getQuarter());
	// }
	// return param;
	// }
	//
	// public List<List<String>> statSource(ReportStatVO reportStatVO) {
	// ReportType reportType = indicatorSystemDao.fetch(ReportType.class, reportStatVO.getReportTypeId());
	// Cnd cnd = Cnd.where("reportTypeId", "=", reportType.getId()).and("indicatorId", "=",
	// reportStatVO.getIndicatorId());
	// ReportTypeIndicatorSystemReport rtis = indicatorSystemDao.fetch(ReportTypeIndicatorSystemReport.class, cnd);
	// List<Record> sources = null;
	// if (reportType.getDataType().intValue() == Constants.ReportStyle.CELL.getValue()) {
	// sources = getCellReportSources(reportStatVO, reportType, rtis);
	// } else {
	// sources = getRowReportSources(reportStatVO, reportType, rtis);
	// }
	//
	// List<List<String>> result = Lists.newArrayList();
	// for (Record re : sources) {
	// List<String> row = Lists.newArrayList();
	// row.add(re.getString("unitName"));
	// String indicatorValue = re.getString("indicatorValue");
	// if (StringUtils.isBlank(indicatorValue)) {
	// row.add("0");
	// } else {
	// row.add(indicatorValue);
	// }
	//
	// result.add(row);
	// }
	//
	// return result;
	// }
	//
	// private List<Record> getRowReportSources(ReportStatVO reportStatVO, ReportType reportType,
	// ReportTypeIndicatorSystemReport rtisr) {
	// List<ReportTypeIndicatorVO> reportIndicatorRels = getReportTypeIndicatorRel(reportStatVO, reportType);
	//
	// // 获取主列
	// ReportTypeIndicatorVO masterIndicator = getRowReportMasterIndicator(reportIndicatorRels, reportType);
	// String sql = "SELECT unit.unit_name unitName,rd.$dataColumn indicatorValue FROM "
	// + " tbl_report r INNER JOIN tbl_report_detail rd ON r.id = rd.report_id "
	// +
	// " INNER JOIN tbl_report_unit ru ON ru.report_id = r.id AND ru.operator_unit = @provinceUnitId AND ru.check_status = '5' "
	// + " INNER JOIN tbl_user u ON r.report_user_id = u.id "
	// + " INNER JOIN tbl_unit unit ON u.user_unit = unit.id "
	// + " INNER JOIN tbl_area area ON unit.unit_area_id = area.id " + " WHERE "
	// + " r.report_check_status = '5' AND u.user_role_id IN ('4','5') "
	// + " AND r.report_type_id = @reportTypeId " + " rd.$masterColumn = @masterValue ";
	// if (reportStatVO.getFrequency() == 0) {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.month = @month ";
	// } else if (reportStatVO.getFrequency() == 1) {
	// sql +=
	// " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.report_year_time = @reportYearTime ";
	// } else {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.quarter = @quarter ";
	// }
	//
	// sql += " AND area.parent_id = @areaId ";
	//
	// Map<String, Object> params = reportStatVOToParamMap(reportStatVO);
	// params.put("provinceUnitId", unitService.getProvinceOceanUnit().getId());
	// params.put("areaId", reportStatVO.getQueryAreaId());
	// params.put("masterValue", reportStatVO.getMasterColumnValue());
	//
	// Map<String, Object> vars = Maps.newHashMap();
	// vars.put("masterColumn", "f" + masterIndicator.getTheColumn().intValue());
	// vars.put("dataColumn", "f" + rtisr.getTheColumn().intValue());
	//
	// return sqlTemplate.queryRecords(sql, vars, params);
	// }
	//
	// private List<Record> getCellReportSources(ReportStatVO reportStatVO, ReportType reportType,
	// ReportTypeIndicatorSystemReport rtisr) {
	//
	// String sql = "SELECT unit.unit_name unitName,rd.$clomun indicatorValue FROM "
	// + " tbl_report r INNER JOIN tbl_report_detail rd ON r.id = rd.report_id "
	// +
	// " INNER JOIN tbl_report_unit ru ON ru.report_id = r.id AND ru.operator_unit = @provinceUnitId AND ru.check_status = '5' "
	// + " INNER JOIN tbl_user u ON r.report_user_id = u.id "
	// + " INNER JOIN tbl_unit unit ON u.user_unit = unit.id "
	// + " INNER JOIN tbl_area area ON unit.unit_area_id = area.id " + " WHERE "
	// + " u.user_role_id IN ('4','5') AND r.report_check_status = '5' "
	// + " AND r.report_type_id = @reportTypeId " + " AND rd.row_index = @row ";
	// if (reportStatVO.getFrequency().intValue() == Constants.REPORT_TIME_MONTH) {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.month = @month ";
	// } else if (reportStatVO.getFrequency().intValue() == Constants.REPORT_TIME_YEAR) {
	// sql +=
	// " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.report_year_time = @reportYearTime ";
	// } else {
	// sql += " AND r.report_timetype = @reportTimetype AND r.report_year = @reportYear AND r.quarter = @quarter ";
	// }
	//
	// Map<String, Object> params = reportStatVOToParamMap(reportStatVO);
	// params.put("provinceUnitId", unitService.getProvinceOceanUnit().getId());
	//
	// sql += " AND area.parent_id = @areaId ";
	// params.put("areaId", reportStatVO.getQueryAreaId());
	// params.put("row", rtisr.getRow());
	//
	// Map<String, Object> vars = Maps.newHashMap();
	// vars.put("clomun", "f" + rtisr.getTheColumn().intValue());
	//
	// return sqlTemplate.queryRecords(sql, vars, params);
	//
	// }

}
